<?php

/**
 * 使用示例
 * @author M2
 * @version 1.0
 * create Date 2013-11-11
 * <yl:block></yl:block>
 */
class YlBlockTaglib {

    public function parse($content) {
        if (stripos($content, 'yl:block') !== false) {
            $matches = preg_parse($content, 'yl:block');
            foreach ($matches as $match) {
                $file = getParseOneAttr($match, 'file');
                $filename = './Public/cms/html/block/' . $file;
                $filename = iconv("UTF-8", "GB2312", $filename);
                if (file_exists($filename)) {
                    $parseStr = read_file($filename);
                    $text = $parseStr;
                } else {
                    $text = '';
                }
                $content = str_replace($match, $text, $content);
            }
        }
        return $content;
    }

}
